package org.poem.publisher;

import org.poem.event.DemoEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * Created by poem on 2017/8/27.
 */
@Component
public class DemoPublisher  {

    /**
     * 使用ApplicationContext来发布消息
     */
    @Autowired
    ApplicationContext context;

    /**
     * 消息发布
     * @param msg
     */
    public void publisher(String msg){
        context.publishEvent(new DemoEvent(this,msg));
    }
}
